define([
  'vue',
  'el-cache',
  'text!' +
  ELMP.resource(
    'components/business-object/index.html',
    'tmzk_workflow'
  ),
  ELMP.resource('components/vue-collapse/index.js', 'lib'),
], function (Vue, elCache, template, vueCollapse) {
  return {
    components: {
      vueCollapse,
    },
    template,
    props: {
      TableHeader: {
        type: Object,
        default: [],
      },
      TableData: {
        type: Array,
        default: [],
      },
      header: { type: String, default: '' },
    },
    data() {
      return {}
    },
    created() { },
    mounted() { },
    methods: {
      clickDil(row, jumpType) {
        if (!jumpType) {
          this.$emit('to-detail', row)
          return
        }
        let url = null
        // 需求详情
        if (jumpType === 'require') {
          window.CACHE_.reqForm = row
          url = ELMP.resource('form.html', 'tmzk_requirement')
        }
        // 项目立项详情
        if (jumpType === 'project') {
          elCache('ppm').use('independent').set('parentProjectId', row.id)
          elCache('ppm').use('independent').set('parentProjectInfo', row)
          if (row.projType === '1') { // 自立类
            url = ELMP.resource('independent/index.html', 'tmzk_project_initiation')

          } else if (row.projType === '2') {// 横向类

            url = ELMP.resource('broadwise/index.html', 'tmzk_project_initiation')

          } else if (row.projType === '3') {// 纵向类

            url = ELMP.resource('portrait/index.html', 'tmzk_project_initiation')

          } else {// 通用类
            url = ELMP.resource('currency/index.html', 'tmzk_project_initiation')

          }
        }
        elCache().use('tmzk_science_achievement').set("scienceAchievement", { rowId: row.id })
        if (jumpType === 'science') {

          elCache().use('tmzk_science_achievement').set('softwareCopyrightInfo', row)
          url = ELMP.resource('software_copyright/form.html', 'tmzk_science_achievement')

        } else if (jumpType === 'standard') {

          elCache().use('tmzk_science_achievement').set('standardInfo', row)
          url = ELMP.resource('standard/form.html', 'tmzk_science_achievement')

        } else if (jumpType === 'paper') {

          elCache().use('tmzk_science_achievement').set('paperInfo', row)
          url = ELMP.resource('paper/form.html', 'tmzk_science_achievement')

        } else if (jumpType === 'opus') {

          elCache().use('tmzk_science_achievement').set('opusInfo', row)
          url = ELMP.resource('opus/form.html', 'tmzk_science_achievement')

        } else if (jumpType === 'newProduct') {

          elCache().use('tmzk_science_achievement').set('newProductInfo', row)
          url = ELMP.resource('new_product/form.html', 'tmzk_science_achievement')

        } else if (jumpType === 'integrated') {

          elCache().use('tmzk_science_achievement').set('integratedInfo', row)
          url = ELMP.resource('integrated_circuit/form.html', 'tmzk_science_achievement')

        } else if (jumpType === 'skillsContract') {

          elCache().use('tmzk_science_achievement').set('skillsContractInfo', row)
          url = ELMP.resource('skills_contract/form.html', 'tmzk_science_achievement')

        }
        else if (jumpType === 'awards') {
          elCache().use('tmzk_science_achievement').set('awardInfo', row)
          url = ELMP.resource('award/form.html', 'tmzk_science_achievement')

        } else if (jumpType === 'achievementAppraisal') {

          elCache().use('tmzk_science_achievement').set('achievementAppraisalInfo', row)
          url = ELMP.resource('science_achievement/form.html', 'tmzk_science_achievement')

        } else { }

        //项目费用预算
        if (jumpType === 'projectCost') {
          elCache().use('tmzk_project_cost').set("row", { 'row': row })
          url = ELMP.resource('independent/components/survey/form.html', 'tmzk_project_cost');
        }


        $.form.sidepage(url, '正在加载', null, null, null)

      },
      // 数据字典转换
      changeDict(row, item) {
        let str = ''
        var val = row[item.prop] ? row[item.prop] : row.flexAttrs[item.prop]
        let arr = $.dict.values(item.dict)
        arr.forEach((c) => {
          if (c.value === val) {
            str = c.displayName
          }
        })
        return str
      },
      setTableData(arr) {
        this.TableData = arr
      },
      getTableData() {
        return this.TableData
      },
    },
  }
})
